T
specifies the type of the value to return
LEADTOOLS Medical (Leadtools.Dicom assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
GetValue<T>(DicomElement,T,T) Method
See Also 
Leadtools.Dicom Namespace > DicomDataSet Class > GetValue Method : GetValue<T>(DicomElement,T,T) Method



element
an item in the data set
defaultValue
a value of type T that is returned if the actual value cannot be retrieved.
value
reference to an object that will be updated with the value.
element
an item in the data set
defaultValue
a value of type T that is returned if the actual value cannot be retrieved.
value
reference to an object that will be updated with the value.
Returns the value of a DICOM element

Syntax

Visual Basic (Declaration) 
Overloads Public Function GetValue(Of T)( _
   ByVal element As DicomElement, _
   ByVal defaultValue As T, _
   ByRef value As T _
) As DicomDataSet
Visual Basic (Usage)Copy Code
Dim instance As DicomDataSet
Dim element As DicomElement
Dim defaultValue As T
Dim value As T
Dim value As DicomDataSet
 
value = instance.GetValue(Of T)(element, defaultValue, value)
C# 
public DicomDataSet GetValue<T>( 
   DicomElement element,
   T defaultValue,
   out T value
)
C++/CLI 
public:
DicomDataSet^ GetValuegeneric<typename T>
( 
   DicomElement^ element,
   T^ defaultValue,
   [Out] T^ value
) 

Parameters

element
an item in the data set
defaultValue
a value of type T that is returned if the actual value cannot be retrieved.
value
reference to an object that will be updated with the value.

Type Parameters

T
specifies the type of the value to return

Return Value

a reference to the DicomDataSet

Example

This example will create a DICOM sequence, and then read back values from the sequence

Visual BasicCopy Code
''' 
Private Sub DicomDataSet_BeginEditSequenceExample()
   ' The methods below all return a 'this' pointer so that they can be chained together (a 'fluent' interface)
   ' BeginEditItem has an index item to allow you to specify which item to edit (defaults to 0).
   ' BeginReadItem should also have this overload.
   '
   ' Create a DicomDataSet 
   Dim ds As DicomDataSet = New DicomDataSet()

   ' ***************************************************
   ' *** Example 1 
   ' ***************************************************

   ' Create a sequence with two items
   ds.BeginEditSequence(DicomTag.RequestAttributesSequence) _
      .BeginEditItem() _
         .InsertElementAndSetValue(DicomTag.RequestedProcedureID, "RequestedProcedureID -- first item") _
         .InsertElementAndSetValue(DicomTag.ScheduledProcedureStepID, "ScheduledProcedureStepID -- first item") _
      .EndEditItem() _
      .BeginEditItem() _
         .InsertElementAndSetValue(DicomTag.RequestedProcedureID, "RequestedProcedureID -- second item") _
         .InsertElementAndSetValue(DicomTag.ScheduledProcedureStepID, "ScheduledProcedureStepID -- second item") _
      .EndEditItem() _
    .EndEditSequence()

   ' Now add a third item to the sequence
   ds.BeginEditSequence(DicomTag.RequestAttributesSequence) _
      .BeginEditItem(2) _
         .InsertElementAndSetValue(DicomTag.RequestedProcedureID, "RequestedProcedureID -- third item") _
         .InsertElementAndSetValue(DicomTag.ScheduledProcedureStepID, "ScheduledProcedureStepID -- third item") _
      .EndEditItem() _
   .EndEditSequence()

   ' Now update the second item in the sequence
   ds.BeginEditSequence(DicomTag.RequestAttributesSequence) _
      .BeginEditItem(1) _
         .InsertElementAndSetValue(DicomTag.RequestedProcedureID, "RequestedProcedureID -- second item updated") _
         .InsertElementAndSetValue(DicomTag.ScheduledProcedureStepID, "ScheduledProcedureStepID -- second item updated") _
      .EndEditItem() _
   .EndEditSequence()

   ' Read the first item in the sequence
   Dim sRequestedProcedureID As String = String.Empty
   Dim sScheduledProcedureStepID As String = String.Empty
   ds.BeginReadSequence(DicomTag.RequestAttributesSequence) _
      .BeginReadItem() _
         .GetValue(Of String)(DicomTag.RequestedProcedureID, Nothing, sRequestedProcedureID) _
         .GetValue(Of String)(DicomTag.ScheduledProcedureStepID, Nothing, sScheduledProcedureStepID) _
      .EndReadItem() _
   .EndReadSequence()

   ' Read the third item in the sequence
   sRequestedProcedureID = String.Empty
   sScheduledProcedureStepID = String.Empty
   ds.BeginReadSequence(DicomTag.RequestAttributesSequence) _
      .BeginReadItem(2) _
         .GetValue(Of String)(DicomTag.RequestedProcedureID, Nothing, sRequestedProcedureID) _
         .GetValue(Of String)(DicomTag.ScheduledProcedureStepID, Nothing, sScheduledProcedureStepID) _
      .EndReadItem() _
   .EndReadSequence()

   ' ***************************************************
   ' *** Example 2 
   ' ***************************************************
   ' This example creates a sequence inside another sequence
   ' Add a per-frame functional gropus sequence with two items
   ds.BeginEditSequence(DicomTag.PerFrameFunctionalGroupsSequence) _
      .BeginEditItem() _
         .BeginEditSequence(DicomTag.FrameVOILUTSequence) _
            .BeginEditItem() _
               .InsertElementAndSetValue(DicomTag.WindowCenter, 32000) _
               .InsertElementAndSetValue(DicomTag.WindowWidth, 64000) _
            .EndEditItem() _
            .BeginEditItem() _
               .InsertElementAndSetValue(DicomTag.WindowCenter, 100) _
               .InsertElementAndSetValue(DicomTag.WindowWidth, 200) _
            .EndEditItem() _
         .EndEditSequence() _
      .EndEditItem() _
   .EndEditSequence()

   ' Now read the per-frame functional groups sequence with two items
   Dim sWindowCenter1 As String = string.Empty
   Dim sWindowWidth1 As String = string.Empty
   Dim sWindowCenter2 As String = string.Empty
   Dim sWindowWidth2 As String = string.Empty
   ds.BeginReadSequence(DicomTag.PerFrameFunctionalGroupsSequence) _
      .BeginReadItem() _
         .BeginReadSequence(DicomTag.FrameVOILUTSequence) _
            .BeginReadItem() _
               .GetValue(Of String)(DicomTag.WindowCenter, Nothing, sWindowCenter1) _
               .GetValue(Of String)(DicomTag.WindowWidth, Nothing, sWindowWidth1) _
            .EndReadItem() _
            .BeginReadItem() _
               .GetValue(Of String)(DicomTag.WindowCenter, Nothing, sWindowCenter2) _
               .GetValue(Of String)(DicomTag.WindowWidth, Nothing, sWindowWidth2) _
            .EndReadItem() _
         .EndReadSequence() _
      .EndReadItem() _
   .EndReadSequence()


   ds.Save(LeadtoolsExamples.Common.ImagesPath.Path + "test.dcm", DicomDataSetSaveFlags.None)

End Sub
C#Copy Code
/// 
private void DicomDataSet_BeginEditSequenceExample()
{
   // The methods below all return a 'this' pointer so that they can be chained together (a 'fluent' interface)
   // BeginEditItem has an index item to allow you to specify which item to edit (defaults to 0).
   // BeginReadItem should also have this overload.
   //
   // Create a DicomDataSet 
   DicomDataSet ds = new DicomDataSet();

   // ***************************************************
   // *** Example 1 
   // ***************************************************

   // Create a sequence with two items
   ds.BeginEditSequence(DicomTag.RequestAttributesSequence)
        .BeginEditItem()
           .InsertElementAndSetValue(DicomTag.RequestedProcedureID, "RequestedProcedureID -- first item")
           .InsertElementAndSetValue(DicomTag.ScheduledProcedureStepID, "ScheduledProcedureStepID -- first item")
        .EndEditItem()
        .BeginEditItem()
           .InsertElementAndSetValue(DicomTag.RequestedProcedureID, "RequestedProcedureID -- second item")
           .InsertElementAndSetValue(DicomTag.ScheduledProcedureStepID, "ScheduledProcedureStepID -- second item")
        .EndEditItem()
     .EndEditSequence();

   // Now add a third item to the sequence
   ds.BeginEditSequence(DicomTag.RequestAttributesSequence)
        .BeginEditItem(2)
           .InsertElementAndSetValue(DicomTag.RequestedProcedureID, "RequestedProcedureID -- third item")
           .InsertElementAndSetValue(DicomTag.ScheduledProcedureStepID, "ScheduledProcedureStepID -- third item")
        .EndEditItem()
     .EndEditSequence();

   // Now update the second item in the sequence
   ds.BeginEditSequence(DicomTag.RequestAttributesSequence)
        .BeginEditItem(1)
           .InsertElementAndSetValue(DicomTag.RequestedProcedureID, "RequestedProcedureID -- second item updated")
           .InsertElementAndSetValue(DicomTag.ScheduledProcedureStepID, "ScheduledProcedureStepID -- second item updated")
        .EndEditItem()
     .EndEditSequence();

   // Read the first item in the sequence
   string sRequestedProcedureID;
   string sScheduledProcedureStepID;
   ds.BeginReadSequence(DicomTag.RequestAttributesSequence)
      .BeginReadItem()
         .GetValue<string>(DicomTag.RequestedProcedureID, null, out sRequestedProcedureID)
         .GetValue<string>(DicomTag.ScheduledProcedureStepID, null, out sScheduledProcedureStepID)
      .EndReadItem()
     .EndReadSequence();

   // Read the third item in the sequence
   sRequestedProcedureID = string.Empty;
   sScheduledProcedureStepID = string.Empty;
   ds.BeginReadSequence(DicomTag.RequestAttributesSequence)
      .BeginReadItem(2)
         .GetValue<string>(DicomTag.RequestedProcedureID, null, out sRequestedProcedureID)
         .GetValue<string>(DicomTag.ScheduledProcedureStepID, null, out sScheduledProcedureStepID)
      .EndReadItem()
     .EndReadSequence();

   // ***************************************************
   // *** Example 2 
   // ***************************************************

   // This example creates a sequence inside another sequence
   // Add a per-frame functional gropus sequence with two items
   ds.BeginEditSequence(DicomTag.PerFrameFunctionalGroupsSequence)
        .BeginEditItem()
               .BeginEditSequence(DicomTag.FrameVOILUTSequence)
                     .BeginEditItem()
                        .InsertElementAndSetValue(DicomTag.WindowCenter, 32000)
                        .InsertElementAndSetValue(DicomTag.WindowWidth, 64000)
                     .EndEditItem()
                     .BeginEditItem()
                        .InsertElementAndSetValue(DicomTag.WindowCenter, 100)
                        .InsertElementAndSetValue(DicomTag.WindowWidth, 200)
                     .EndEditItem()
               .EndEditSequence()
        .EndEditItem()
     .EndEditSequence();

   // Now read the per-frame functional groups sequence with two items
   string sWindowCenter1;
   string sWindowWidth1;
   string sWindowCenter2;
   string sWindowWidth2;
   ds.BeginReadSequence(DicomTag.PerFrameFunctionalGroupsSequence)
      .BeginReadItem()
         .BeginReadSequence(DicomTag.FrameVOILUTSequence)
            .BeginReadItem()
                .GetValue<string>(DicomTag.WindowCenter, null, out sWindowCenter1)
                .GetValue<string>(DicomTag.WindowWidth, null, out sWindowWidth1)
            .EndReadItem()
            .BeginReadItem()
                .GetValue<string>(DicomTag.WindowCenter, null, out sWindowCenter2)
                .GetValue<string>(DicomTag.WindowWidth, null, out sWindowWidth2)
            .EndReadItem()
         .EndReadSequence()
      .EndReadItem()
   .EndReadSequence();

   ds.Save(LeadtoolsExamples.Common.ImagesPath.Path + "test.dcm", DicomDataSetSaveFlags.None);

}
SilverlightCSharpCopy Code
private void DicomDataSet_BeginEditSequenceExample(Stream outputStream)
{
   // The methods below all return a 'this' pointer so that they can be chained together (a 'fluent' interface)
   // BeginEditItem has an index item to allow you to specify which item to edit (defaults to 0).
   // BeginReadItem should also have this overload.
   //
   // Create a DicomDataSet 
   DicomDataSet ds = new DicomDataSet();

   // ***************************************************
   // *** Example 1 
   // ***************************************************

   // Create a sequence with two items
   ds.BeginEditSequence(DicomTag.RequestAttributesSequence)
        .BeginEditItem()
           .InsertElementAndSetValue(DicomTag.RequestedProcedureID, "RequestedProcedureID -- first item")
           .InsertElementAndSetValue(DicomTag.ScheduledProcedureStepID, "ScheduledProcedureStepID -- first item")
        .EndEditItem()
        .BeginEditItem()
           .InsertElementAndSetValue(DicomTag.RequestedProcedureID, "RequestedProcedureID -- second item")
           .InsertElementAndSetValue(DicomTag.ScheduledProcedureStepID, "ScheduledProcedureStepID -- second item")
        .EndEditItem()
     .EndEditSequence();

   // Now add a third item to the sequence
   ds.BeginEditSequence(DicomTag.RequestAttributesSequence)
        .BeginEditItem(2)
           .InsertElementAndSetValue(DicomTag.RequestedProcedureID, "RequestedProcedureID -- third item")
           .InsertElementAndSetValue(DicomTag.ScheduledProcedureStepID, "ScheduledProcedureStepID -- third item")
        .EndEditItem()
     .EndEditSequence();

   // Now update the second item in the sequence
   ds.BeginEditSequence(DicomTag.RequestAttributesSequence)
        .BeginEditItem(1)
           .InsertElementAndSetValue(DicomTag.RequestedProcedureID, "RequestedProcedureID -- second item updated")
           .InsertElementAndSetValue(DicomTag.ScheduledProcedureStepID, "ScheduledProcedureStepID -- second item updated")
        .EndEditItem()
     .EndEditSequence();

   // Read the first item in the sequence
   string sRequestedProcedureID;
   string sScheduledProcedureStepID;
   ds.BeginReadSequence(DicomTag.RequestAttributesSequence)
      .BeginReadItem()
         .GetValue<string>(DicomTag.RequestedProcedureID, null, out sRequestedProcedureID)
         .GetValue<string>(DicomTag.ScheduledProcedureStepID, null, out sScheduledProcedureStepID)
      .EndReadItem()
     .EndReadSequence();

   // Read the third item in the sequence
   sRequestedProcedureID = string.Empty;
   sScheduledProcedureStepID = string.Empty;
   ds.BeginReadSequence(DicomTag.RequestAttributesSequence)
      .BeginReadItem(2)
         .GetValue<string>(DicomTag.RequestedProcedureID, null, out sRequestedProcedureID)
         .GetValue<string>(DicomTag.ScheduledProcedureStepID, null, out sScheduledProcedureStepID)
      .EndReadItem()
     .EndReadSequence();

   // ***************************************************
   // *** Example 2 
   // ***************************************************

   // This example creates a sequence inside another sequence
   // Add a per-frame functional gropus sequence with two items
   ds.BeginEditSequence(DicomTag.PerFrameFunctionalGroupsSequence)
        .BeginEditItem()
               .BeginEditSequence(DicomTag.FrameVOILUTSequence)
                     .BeginEditItem()
                        .InsertElementAndSetValue(DicomTag.WindowCenter, 32000)
                        .InsertElementAndSetValue(DicomTag.WindowWidth, 64000)
                     .EndEditItem()
                     .BeginEditItem()
                        .InsertElementAndSetValue(DicomTag.WindowCenter, 100)
                        .InsertElementAndSetValue(DicomTag.WindowWidth, 200)
                     .EndEditItem()
               .EndEditSequence()
        .EndEditItem()
     .EndEditSequence();

   // Now read the per-frame functional groups sequence with two items
   string sWindowCenter1;
   string sWindowWidth1;
   string sWindowCenter2;
   string sWindowWidth2;
   ds.BeginReadSequence(DicomTag.PerFrameFunctionalGroupsSequence)
      .BeginReadItem()
         .BeginReadSequence(DicomTag.FrameVOILUTSequence)
            .BeginReadItem()
                .GetValue<string>(DicomTag.WindowCenter, null, out sWindowCenter1)
                .GetValue<string>(DicomTag.WindowWidth, null, out sWindowWidth1)
            .EndReadItem()
            .BeginReadItem()
                .GetValue<string>(DicomTag.WindowCenter, null, out sWindowCenter2)
                .GetValue<string>(DicomTag.WindowWidth, null, out sWindowWidth2)
            .EndReadItem()
         .EndReadSequence()
      .EndReadItem()
   .EndReadSequence();

   ds.Save(outputStream, DicomDataSetSaveFlags.None);

}
SilverlightVBCopy Code
Private Sub DicomDataSet_BeginEditSequenceExample(ByVal outputStream As Stream)
   ' The methods below all return a 'this' pointer so that they can be chained together (a 'fluent' interface)
   ' BeginEditItem has an index item to allow you to specify which item to edit (defaults to 0).
   ' BeginReadItem should also have this overload.
   '
   ' Create a DicomDataSet 
   Dim ds As DicomDataSet = New DicomDataSet()

   ' ***************************************************
   ' *** Example 1 
   ' ***************************************************

   ' Create a sequence with two items
   With ds.BeginEditSequence(DicomTag.RequestAttributesSequence)
      .BeginEditItem()
      .InsertElementAndSetValue(DicomTag.RequestedProcedureID, "RequestedProcedureID -- first item")
      .InsertElementAndSetValue(DicomTag.ScheduledProcedureStepID, "ScheduledProcedureStepID -- first item")
      .EndEditItem()
      .BeginEditItem()
      .InsertElementAndSetValue(DicomTag.RequestedProcedureID, "RequestedProcedureID -- second item")
      .InsertElementAndSetValue(DicomTag.ScheduledProcedureStepID, "ScheduledProcedureStepID -- second item")
      .EndEditItem()
      .EndEditSequence()
   End With

   ' Now add a third item to the sequence
   With ds.BeginEditSequence(DicomTag.RequestAttributesSequence)
      .BeginEditItem(2)
      .InsertElementAndSetValue(DicomTag.RequestedProcedureID, "RequestedProcedureID -- third item")
      .InsertElementAndSetValue(DicomTag.ScheduledProcedureStepID, "ScheduledProcedureStepID -- third item")
      .EndEditItem()
      .EndEditSequence()
   End With

   ' Now update the second item in the sequence
   With ds.BeginEditSequence(DicomTag.RequestAttributesSequence)
      .BeginEditItem(1)
      .InsertElementAndSetValue(DicomTag.RequestedProcedureID, "RequestedProcedureID -- second item updated")
      .InsertElementAndSetValue(DicomTag.ScheduledProcedureStepID, "ScheduledProcedureStepID -- second item updated")
      .EndEditItem()
      .EndEditSequence()
   End With

   ' Read the first item in the sequence
   Dim sRequestedProcedureID As String = String.Empty
   Dim sScheduledProcedureStepID As String = String.Empty
   With ds.BeginReadSequence(DicomTag.RequestAttributesSequence)
      .BeginReadItem()
      .GetValue(Of String)(DicomTag.RequestedProcedureID, Nothing, sRequestedProcedureID)
      .GetValue(Of String)(DicomTag.ScheduledProcedureStepID, Nothing, sScheduledProcedureStepID)
      .EndReadItem()
      .EndReadSequence()
   End With

   ' Read the third item in the sequence
   sRequestedProcedureID = String.Empty
   sScheduledProcedureStepID = String.Empty
   With ds.BeginReadSequence(DicomTag.RequestAttributesSequence)
      .BeginReadItem(2)
      .GetValue(Of String)(DicomTag.RequestedProcedureID, Nothing, sRequestedProcedureID)
      .GetValue(Of String)(DicomTag.ScheduledProcedureStepID, Nothing, sScheduledProcedureStepID)
      .EndReadItem()
      .EndReadSequence()
   End With

   ' ***************************************************
   ' *** Example 2 
   ' ***************************************************

   ' This example creates a sequence inside another sequence
   ' Add a per-frame functional gropus sequence with two items
   With ds.BeginEditSequence(DicomTag.PerFrameFunctionalGroupsSequence)
      .BeginEditItem()
      .BeginEditSequence(DicomTag.FrameVOILUTSequence)
      .BeginEditItem()
      .InsertElementAndSetValue(DicomTag.WindowCenter, 32000)
      .InsertElementAndSetValue(DicomTag.WindowWidth, 64000)
      .EndEditItem()
      .BeginEditItem()
      .InsertElementAndSetValue(DicomTag.WindowCenter, 100)
      .InsertElementAndSetValue(DicomTag.WindowWidth, 200)
      .EndEditItem()
      .EndEditSequence()
      .EndEditItem()
      .EndEditSequence()
   End With

   ' Now read the per-frame functional groups sequence with two items
   Dim sWindowCenter1 As String = String.Empty
   Dim sWindowWidth1 As String = String.Empty
   Dim sWindowCenter2 As String = String.Empty
   Dim sWindowWidth2 As String = String.Empty
   With ds.BeginReadSequence(DicomTag.PerFrameFunctionalGroupsSequence)
      .BeginReadItem()
      .BeginReadSequence(DicomTag.FrameVOILUTSequence)
      .BeginReadItem()
      .GetValue(Of String)(DicomTag.WindowCenter, Nothing, sWindowCenter1)
      .GetValue(Of String)(DicomTag.WindowWidth, Nothing, sWindowWidth1)
      .EndReadItem()
      .BeginReadItem()
      .GetValue(Of String)(DicomTag.WindowCenter, Nothing, sWindowCenter2)
      .GetValue(Of String)(DicomTag.WindowWidth, Nothing, sWindowWidth2)
      .EndReadItem()
      .EndReadSequence()
      .EndReadItem()
      .EndReadSequence()
   End With

   ds.Save(outputStream, DicomDataSetSaveFlags.None)
End Sub

Remarks

For information on this method, see GetValue.

Requirements

Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)

See Also

Leadtools.Dicom requires a Medical toolkit server license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features